package net.wanho.ums.controller;

import lombok.RequiredArgsConstructor;
import net.wanho.ums.entity.User;
import net.wanho.ums.service.UserService;
import net.wanho.ums.vo.AjaxResult;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * Author：汤小洋
 * Date：2023-09-22 9:43
 * Description：<描述>
 */
@RestController
@RequestMapping("/user")
@RequiredArgsConstructor
public class UserController {

    private final UserService userService;

    @PostMapping("/add")
    public AjaxResult add(@RequestBody User user){
        userService.add(user);
        return AjaxResult.success();
    }

    @GetMapping("/queryByPage")
    public AjaxResult queryByPage(@RequestParam(required = false, defaultValue = "1") int pageNum,
                                  @RequestParam(required = false, defaultValue = "5") int pageSize,User user){
        return AjaxResult.success(userService.findByPage(pageNum,pageSize,user));
    }

    @GetMapping("/query/{id}")
    public AjaxResult queryById(@PathVariable int id){

        return AjaxResult.success();
    }

    @DeleteMapping("/remove/{id}")
    public AjaxResult remove(@PathVariable int id){
        userService.removeById(id);
        return AjaxResult.success();
    }

    @DeleteMapping("/removeBatch")
    public AjaxResult removeBatch(@RequestBody List<Integer> ids){
        return AjaxResult.success();
    }

    @PutMapping("/modify")
    public AjaxResult modify(@RequestBody User user){

        return AjaxResult.success();
    }

    @PutMapping("/modifyStatus/{id}/{status}")
    public AjaxResult modifyStatus(@PathVariable int id,@PathVariable int status){

        return AjaxResult.success();
    }

}
